<%@page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="html" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<html:header title="进货退货报表">

    <script src="${baseUrl}js/myEchart.js" charset="utf-8"></script>
    <link rel="stylesheet" href="${baseUrl}css/public.css" media="all">

    <style type="text/css">
        .layui-card {border:1px solid #f2f2f2;border-radius:5px;}
        .panel {background-color:#fff;border:1px solid transparent;border-radius:3px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}
        .panel-body {padding:10px}
        .panel-title {margin-top:0;margin-bottom:0;font-size:12px;color:inherit}
        .layui-bg-number {background-color:#F8F8F8;}
    </style>



    <script>


        let option = {
            elem: '#selectHouse'
            ,placeholder:"全部"
            ,width:160
            , value: "0"
            ,clear:true
            , getChildren: function (value, callback) {
                var data = [];
                //表示是门店
                if (value == "0"){
                    get("${baseUrl}organization/store/getStores.action", function (res) {
                        if (res.code == 1){
                            data.push({value:"", label:"全部"});
                            $.each(res.data, function (i,d) {
                                data.push({value:d.id, label:d.name, hasChild:true});
                            });
                            callback(data);
                        }
                    });
                } else {
                    //表示是仓库
                    get("${baseUrl}organization/house/getHouseByStore.action?storeId="+value, function (res) {
                        if (res.code == 1){
                            data.push({value:"", label:"全部"});
                            $.each(res.data, function (i,d) {
                                data.push({value:d.id, label:d.name});
                            });

                            callback(data);
                        }
                    });
                }
            }
        };




        jQuery(function () {
            fixTableOperatorButton();
            ajaxSelect("${baseUrl}goods/type/getAll.action","typeId_goods","全部");
            ajaxSelect("${baseUrl}provider/providerType/getAll.action","providerTypeId_provider","全部");
        });


        layui.use(['form', 'table','laydate','ajaxCascader','laytpl','element'], function () {
            let $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                laydate = layui.laydate,
                laytpl = layui.laytpl,
                cascader = layui.ajaxCascader,
                element = layui.element,
                util = layui.util;

            laydate.render({
                elem: '#date',
                range:'~',
                done: function(value, date, endDate){
                    if (!emptyEntity(value)) {
                        $('[name="date1"]').val(getDateFromLayUiDate(date));
                        $('[name="date2"]').val(getDateFromLayUiDate(endDate));
                    } else {
                        $('[name="date1"]').val('');
                        $('[name="date2"]').val('');
                    }

                    getAllTotalData();
                    loadView();
                }
            });

            $(".view-button-group .layui-btn").click(function () {
                tabButtonClick(this);
                loadView();
            });

            $(".tab-button-group .layui-btn").click(function () {
                tabButtonClick(this);
                loadTableView();
            });

            getAllTotalData();
            renderGoodsTable();

            table.on('tool(table_goods)', function (obj) {
                let data = obj.data;
                if(obj.event == 'detail'){
                    openTab("进货退货报表按商品详情","${baseUrl}goodsCount/inGoodsRefundAnalysisDetailGoods.action"+genParam(genSearch_goods()) + "&goodsId="+data.id);
                }
            });

            table.on('tool(table_provider)', function (obj) {
                let data = obj.data;
                if(obj.event == 'detail'){
                    openTab("进货退货报表按供应商详情","${baseUrl}goodsCount/inGoodsRefundAnalysisDetailProvider.action"+genParam(genSearch_goods()) + "&providerId="+data.id);
                }
            });

            table.on('tool(table_order)', function (obj) {
                let data = obj.data;
                if(obj.event == 'detail'){
                    openTab("进货退货报表按单据详情","${baseUrl}goodsCount/inGoodsRefundAnalysisDetailOrder.action?date="+data.date);
                }
            });


            $("#export-goods").click(function () {
                exportExcel_goods();
            });
            $("#export-provider").click(function () {
                exportExcel_provider();
            });
            $("#export-order").click(function () {
                exportExcel_order();
            });

            // Ajax传参模式
            cascader.load(option);

            // 选择器点击事件的监听
            cascader.on('click', '#selectHouse', function(data){
                let datas = cascader.getChooseData();
                $("[name='storeId']").val(datas[0]);
                $("[name='houseId']").val(datas[1]);

                getAllTotalData();
                loadView();
            });

            $(".cascader-clear").click(function () {
                $("[name='houseId']").val("");
                $("[name='storeId']").val("");

                getAllTotalData();
                loadView();
            });




            form.on('select(typeId_goods)', function (data) {
                table.reload('table_goods',{where: genSearch_goods(),page: {curr: 1}});
            });

            form.on('checkbox(filterZero_goods)', function (data) {
                table.reload('table_goods',{where: genSearch_goods(),page: {curr: 1}});
            });

            form.on('submit(search_goods)', function (data) {
                table.reload('table_goods',{where: genSearch_goods(),page: {curr: 1}});
                return false;
            });

            form.on('select(providerTypeId_provider)', function (data) {
                table.reload('table_provider',{where: genSearch_provider(),page: {curr: 1}});
            });

            form.on('checkbox(filterZero_provider)', function (data) {
                table.reload('table_provider',{where: genSearch_provider(),page: {curr: 1}});
            });

            form.on('submit(search_provider)', function (data) {
                table.reload('table_provider',{where: genSearch_provider(),page: {curr: 1}});
                return false;
            });
        });


        function exportExcel_goods() {
            confirm("是否导出?",function () {
                tipLoad("处理中，请稍后");
                post("${baseUrl}goodsCount/inGoodsRefundAnalysis/exportGoodsData.action"+ genParam(genSearch_goods()),{},function (res) {
                    closeAll();
                    if (res.code == 1) {
                        downloadFileByForm("${baseUrl}file/excel/temp/"+res.data);
                    }  else {
                        tip(res.msg);
                    }
                });
            });
        }


        function exportExcel_provider() {
            confirm("是否导出?",function () {
                tipLoad("处理中，请稍后");
                post("${baseUrl}goodsCount/inGoodsRefundAnalysis/exportProviderData.action"+ genParam(genSearch_provider()),{},function (res) {
                    closeAll();
                    if (res.code == 1) {
                        downloadFileByForm("${baseUrl}file/excel/temp/"+res.data);
                    }  else {
                        tip(res.msg);
                    }
                });
            });
        }

        function exportExcel_order() {
            confirm("是否导出?",function () {
                tipLoad("处理中，请稍后");
                post("${baseUrl}goodsCount/inGoodsRefundAnalysis/exportOrderData.action"+ genParam(genSearch_order()),{},function (res) {
                    closeAll();
                    if (res.code == 1) {
                        downloadFileByForm("${baseUrl}file/excel/temp/"+res.data);
                    }  else {
                        tip(res.msg);
                    }
                });
            });
        }

        function genSearch_goods() {
            let json = getFormJson($("#searchForm"));
            json.typeId = json.typeId_goods;
            json.search = json.search_goods;
            json.fileName = json.fileName_goods;
            json.filterZero = $('[name="filterZero_goods"]').next().hasClass("layui-form-checked") ? true:'';
            return json;
        }

        function genSearch_provider() {
            let json = getFormJson($("#searchForm"));
            json.providerTypeId = json.providerTypeId_provider;
            json.search = json.search_provider;
            json.fileName = json.fileName_provider;
            json.filterZero = $('[name="filterZero_provider"]').next().hasClass("layui-form-checked") ? true:'';
            return json;
        }

        function genSearch_order() {
            let json = getFormJson($("#searchForm"));
            json.fileName = json.fileName_order;
            return json;
        }


        function getAllTotalData() {
            let houseId = $('[name="houseId"]').val();
            let storeId = $('[name="storeId"]').val();
            let date1 = $('[name="date1"]').val();
            let date2 = $('[name="date2"]').val();
            get("${baseUrl}goodsCount/inGoodsRefundAnalysis/getAllTotalData.action?storeId="+storeId+"&houseId="+houseId+"&date1="+date1+"&date2="+date2, function (res) {
                if (res.code == 1 && !emptyList(res.data)) {
                    $("#inGoodsRefundNumber").html(res.data.total_number);
                    $("#inGoodsRefundAmount").html(getPrice(res.data.total_amt));
                    if (emptyList(res.data.highGoods)) {
                        $("#highGoods").html("无");
                    } else {
                        $("#highGoods").html(res.data.highGoods.name);
                    }

                    if (emptyList(res.data.highProvider)) {
                        $("#highProvider").html("无");
                    } else {
                        $("#highProvider").html(res.data.highProvider.name);
                    }
                }
            });
        }

        function renderGoodsTable() {
            layui.table.render({
                id:'table_goods',
                elem: '#table_goods',
                totalRow:true,
                url: "${baseUrl}goodsCount/inGoodsRefundAnalysis/listGoodsData.action",
                where : genSearch_goods(),
                cols: [[
                    {width:70,title:"序号",templet:function (d) {
                            return d.LAY_INDEX;;
                        }},
                    {field: 'no', width: 130, title: '商品编号',style:"font-size:12px;"},
                    {field: 'name',width: 150, title: '商品名称',style:"font-size:12px;"},
                    {field: 'norms',width: 120, title: '规格',style:"font-size:12px;"},
                    {field: 'unitName',width: 80, title: '单位',style:"font-size:12px;"},

                    {field: 'number',width: 120, title: '进货退货量',style:"font-size:12px;"},
                    {field: 'amount',width: 120, title: '进货退货额',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.amount);
                        }},
                    {field: 'avgAmount',width: 120, title: '进货退货均价',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.avgAmount);
                        }},
                    {field: 'profits',width: 120, title: '毛利',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.profits);
                        }},
                    {field: 'tax',width: 120, title: '税额',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.tax);
                        }},
                    {title: '操作', minWidth: 80,fixed:'right', templet: '#operBar'},
                ]],
                limit: 10,
                page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                    //,curr: 5 //设定初始在第 5 页
                    ,groups: 5 //只显示 5 个连续页码
                    ,first: false //不显示首页
                    ,last: false //不显示尾页
                },
                done: function(res, curr, count){
                    let number = 0;
                    let amount = 0;
                    let profits = 0;
                    let tax = 0;
                    $.each(res.data, function (i,d) {
                        number += parseFloat(d.number);
                        amount += parseFloat(d.amount);
                        profits += parseFloat(d.profits);
                        tax += parseFloat(d.tax);
                    });
                    setTotalRowWithParent($('[lay-id="table_goods"]'),"number",getNumber(number));
                    setTotalRowWithParent($('[lay-id="table_goods"]'),"amount",getPrice(amount));
                    setTotalRowWithParent($('[lay-id="table_goods"]'),"profits",getPrice(profits));
                    setTotalRowWithParent($('[lay-id="table_goods"]'),"tax",getPrice(tax));
                    setTotalRowWithParent($('[lay-id="table_goods"]'),"0","合计");
                }
            });
        }

        function renderProviderTable() {
            layui.table.render({
                id:'table_provider',
                elem: '#table_provider',
                totalRow:true,
                url: "${baseUrl}goodsCount/inGoodsRefundAnalysis/listProviderData.action",
                where :genSearch_provider(),
                cols: [[
                    {width:70,title:"序号",templet:function (d) {
                            return d.LAY_INDEX;;
                        }},
                    {field: 'no', width: 130, title: '供应商编号',style:"font-size:12px;"},
                    {field: 'name',width: 150, title: '供应商名称',style:"font-size:12px;"},
                    {field: 'number',width: 120, title: '进货退货量',style:"font-size:12px;"},
                    {field: 'amount',width: 120, title: '进货退货额',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.amount);
                        }},
                    {field: 'ratio',width: 120, title: '进货退货比重',style:"font-size:12px;",templet: function (d) {
                            return getNumber(d.ratio)+'%';
                        }},
                    {field: 'profits',width: 120, title: '毛利',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.profits);
                        }},
                    {field: 'discountAmt',width: 120, title: '折扣额',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.discountAmt);
                        }},
                    {field: 'tax',width: 120, title: '税额',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.tax);
                        }},
                    {title: '操作', minWidth: 80,fixed:'right', templet: '#operBar'},
                ]],
                limit: 10,
                page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                    //,curr: 5 //设定初始在第 5 页
                    ,groups: 5 //只显示 5 个连续页码
                    ,first: false //不显示首页
                    ,last: false //不显示尾页
                },
                done: function(res, curr, count){
                    let number = 0;
                    let amount = 0;
                    let profits = 0;
                    let discountAmt = 0;
                    let tax = 0;
                    $.each(res.data, function (i,d) {
                        number += parseFloat(d.number);
                        amount += parseFloat(d.amount);
                        profits += parseFloat(d.profits);
                        discountAmt += parseFloat(d.discountAmt);
                        tax += parseFloat(d.tax);
                    });


                    setTotalRowWithParent($('[lay-id="table_provider"]'),"number",getNumber(number));
                    setTotalRowWithParent($('[lay-id="table_provider"]'),"amount",getPrice(amount));
                    setTotalRowWithParent($('[lay-id="table_provider"]'),"profits",getPrice(profits));
                    setTotalRowWithParent($('[lay-id="table_provider"]'),"discountAmt",getPrice(discountAmt));
                    setTotalRowWithParent($('[lay-id="table_provider"]'),"tax",getPrice(tax));
                    setTotalRowWithParent($('[lay-id="table_provider"]'),"0","合计");
                }
            });
        }

        function renderOrderTable() {
            layui.table.render({
                id:'table_order',
                elem: '#table_order',
                totalRow:true,
                url: "${baseUrl}goodsCount/inGoodsRefundAnalysis/listOrderData.action",
                where : genSearch_order(),
                cols: [[
                    {width:70,title:"序号",templet:function (d) {
                            return d.LAY_INDEX;;
                        }},
                    {field: 'date', width: 130, title: '日期',style:"font-size:12px;"},
                    {field: 'number',width: 120, title: '进货退货笔数',style:"font-size:12px;"},
                    {field: 'amount',width: 120, title: '进货退货额',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.amount);
                        }},
                    {field: 'cost',width: 120, title: '成本',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.cost);
                        }},
                    {field: 'profits',width: 120, title: '毛利',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.profits);
                        }},
                    {field: 'tax',width: 120, title: '税额',style:"font-size:12px;",templet: function (d) {
                            return getPrice(d.tax);
                        }},
                    {title: '操作', minWidth: 80,fixed:'right', templet: '#operBar'},
                ]],
                limit: 10,
                page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                    //,curr: 5 //设定初始在第 5 页
                    ,groups: 5 //只显示 5 个连续页码
                    ,first: false //不显示首页
                    ,last: false //不显示尾页
                },
                done: function(res, curr, count){
                    let number = 0;
                    let amount = 0;
                    let cost = 0;
                    let profits = 0;
                    let inGoodsRefundNumber = 0;
                    let tax = 0;
                    $.each(res.data, function (i,d) {
                        number += parseFloat(d.number);
                        amount += parseFloat(d.amount);
                        profits += parseFloat(d.profits);
                        inGoodsRefundNumber += parseFloat(d.inGoodsRefundNumber);
                        tax += parseFloat(d.tax);
                    });

                    setTotalRowWithParent($('[lay-id="table_order"]'),"number",getNumber(number));
                    setTotalRowWithParent($('[lay-id="table_order"]'),"amount",getPrice(amount));
                    setTotalRowWithParent($('[lay-id="table_order"]'),"profits",getPrice(profits));
                    setTotalRowWithParent($('[lay-id="table_order"]'),"inGoodsRefundNumber",getPrice(inGoodsRefundNumber));
                    setTotalRowWithParent($('[lay-id="table_order"]'),"tax",getPrice(tax));
                    setTotalRowWithParent($('[lay-id="table_order"]'),"0","合计");
                }
            });
        }


        function loadTableView() {
            var id = $(".tab-button-group").find(".layui-this").attr("view-id");
            if(id.indexOf("goods") != -1) {
                renderGoodsTable();
            } else if(id.indexOf("provider") != -1) {
                renderProviderTable();
            } else if(id.indexOf("order") != -1) {
                renderOrderTable();
            }
        }

        function loadView(){
            var viewId = $(".view-button-group .layui-this").attr("view-id");

            if (viewId.indexOf("table") != -1) {
                loadTableView();
            } else {
                loadChartView();
            }
        }
    </script>

</html:header>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="" id="searchForm">
            <input type="hidden" name="houseId">
            <input type="hidden" name="storeId">
            <input type="hidden" name="date1">
            <input type="hidden" name="date2">
            <input type="hidden" name="fileName_goods" value="进货退货报表按商品表">
            <input type="hidden" name="fileName_provider" value="进货退货报表按供应商表">
            <input type="hidden" name="fileName_order" value="进货退货报表按单据表">

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">门店仓库</label>
                    <div class="layui-input-inline">
                        <cascader id="selectHouse"></cascader>
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">日期范围</label>
                    <div class="layui-input-inline">
                        <input type="text" id="date" placeholder="请选择日期" class="layui-input" autocomplete="off">
                    </div>
                </div>

                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <div class="layui-btn-group view-button-group">
                            <a view-id="table-div" view-class="view-div" class="layui-btn layui-btn-normal fontWhite layui-this">列表视图</a>
                            <a view-id="chat-div" view-class="view-div" class="layui-btn layui-btn-primary fontBlue">图表视图</a>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="w100">
                        <div class="layui-row layui-col-space10">
                            <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
                                <div class="panel layui-bg-number">
                                    <div class="panel-body">
                                        <div class="panel-title">
                                            <h5>进货退货笔数</h5>
                                        </div>
                                        <div class="panel-content">
                                            <span class="fontB fontRed font24" id="inGoodsRefundNumber">0</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
                                <div class="panel layui-bg-number">
                                    <div class="panel-body">
                                        <div class="panel-title">
                                            <h5>进货退货额</h5>
                                        </div>
                                        <div class="panel-content">
                                            <span class="fontB fontRed font24" id="inGoodsRefundAmount"></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                                <div class="panel layui-bg-number">
                                    <div class="panel-body">
                                        <div class="panel-title">
                                            <h5>进货退货额最高商品</h5>
                                        </div>
                                        <div class="panel-content">
                                            <span class=" fontB fontDeepBlue font14" id="highGoods">无</span>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
                                <div class="panel layui-bg-number">
                                    <div class="panel-body">
                                        <div class="panel-title">
                                            <h5>进货退货额最高供应商</h5>
                                        </div>
                                        <div class="panel-content">
                                            <span class=" fontB fontDeepBlue font14" id="highProvider">无</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div id="chat-div" class="w100 view-div" style="display: none">
                <div>
                    <div class="layui-card">
                        <div class="layui-card-header">
                            进货退货排行
                        </div>
                        <div class="layui-card-body">
                            <div class="layui-inline">
                                <div class="layui-btn-group chat-rank-button-group">
                                    <a class="layui-btn layui-btn-normal fontWhite layui-this goods">按商品</a>
                                    <a class="layui-btn layui-btn-primary fontBlue store">按门店</a>
                                    <a class="layui-btn layui-btn-primary fontBlue house">按仓库</a>
                                </div>
                            </div>

                            <div id="chat-rank" class="h300"></div>

                            <div class="h300 lh300 font20 fontB fontC_ccc" style="text-align: center;display: none;">
                                统计值为0或负数无法统计
                            </div>
                        </div>
                    </div>
                </div>

                <div>
                    <div class="layui-card">
                        <div class="layui-card-header">
                            进货退货比重
                        </div>
                        <div class="layui-card-body">
                            <div class="layui-inline">
                                <div class="layui-btn-group chat-ratio-button-group">
                                    <a class="layui-btn layui-btn-normal fontWhite layui-this goods">按商品</a>
                                    <a class="layui-btn layui-btn-primary fontBlue store">按门店</a>
                                    <a class="layui-btn layui-btn-primary fontBlue house">按仓库</a>
                                </div>
                            </div>

                            <div id="chat-ratio" class="h300"></div>

                            <div class="h300 lh300 font20 fontB fontC_ccc" style="text-align: center;display: none;">
                                统计值为0或负数无法统计
                            </div>
                        </div>
                    </div>
                </div>

                <div>
                    <div class="layui-card">
                        <div class="layui-card-header">
                            供应商进货退货比重
                        </div>
                        <div class="layui-card-body">
                            <div id="provider-ratio" class="h300"></div>

                            <div class="h300 lh300 font20 fontB fontC_ccc" style="text-align: center;display: none;">
                                统计值为0或负数无法统计
                            </div>
                        </div>
                    </div>
                </div>

                <div>
                    <div class="layui-card">
                        <div class="layui-card-header">进货退货趋势</div>
                        <div class="layui-card-body">
                            <div id="inGoodsRefund-trend" class="h300"></div>
                            <div class="h300 lh300 font20 fontB fontC_ccc" style="text-align: center;display: none;">
                                统计值为0或负数无法统计
                            </div>
                        </div>
                    </div>
                </div>

                <script>
                    function loadChartView(){

                        layui.use(['form', 'echarts'], function () {
                            let $ = layui.jquery,
                                form = layui.form,
                                echarts = layui.echarts;
                            window.chat_rank_chat = echarts.init(document.getElementById('chat-rank'),'walden');
                            window.chat_ratio_chat = echarts.init(document.getElementById('chat-ratio'),'walden');
                            window.provider_ratio_chat = echarts.init(document.getElementById('provider-ratio'),'walden');
                            window.inGoodsRefund_trend_chat = echarts.init(document.getElementById('inGoodsRefund-trend'),'walden');

                            window.onresize = function(){
                                window.provider_ratio_chat.resize();
                                window.chat_ratio_chat.resize();
                                window.chat_rank_chat.resize();
                                window.inGoodsRefund_trend_chat.resize();
                            };

                            $(".chat-rank-button-group .layui-btn").click(function () {
                                tabButtonClick(this);
                                let url;
                                if ($(".chat-rank-button-group").find(".layui-this").hasClass("goods")) {
                                    url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listGoodsData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                                } else if ($(".chat-rank-button-group").find(".layui-this").hasClass("store")) {
                                    url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listStoreData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                                } else if ($(".chat-rank-button-group").find(".layui-this").hasClass("house")) {
                                    url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listHouseData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                                }
                                get(url, function (res) {
                                    if (!emptyList(res.data)) {
                                        $("#chat-rank").css("display","block");
                                        $("#chat-rank").next().css("display","none");
                                        window.chat_rank_chat.setOption(genChatRankOption(genChatRankData("进货退货额","amount",res.data)));
                                    } else {
                                        $("#chat-rank").css("display","none");
                                        $("#chat-rank").next().css("display","block");
                                    }
                                });
                            });

                            $(".chat-ratio-button-group .layui-btn").click(function () {
                                tabButtonClick(this);
                                let url;
                                if ($(".chat-ratio-button-group").find(".layui-this").hasClass("goods")) {
                                    url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listGoodsData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                                } else if ($(".chat-ratio-button-group").find(".layui-this").hasClass("store")) {
                                    url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listStoreData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                                } else if ($(".chat-ratio-button-group").find(".layui-this").hasClass("house")) {
                                    url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listHouseData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                                }

                                get(url, function (res) {
                                    if (!emptyList(res.data)) {
                                        $("#chat-ratio").css("display","block");
                                        $("#chat-ratio").next().css("display","none");
                                        window.chat_ratio_chat.setOption(genChatRatioOption(genChatRatioData("进货退货额","amount",res.data)));
                                    } else {
                                        $("#chat-ratio").css("display","none");
                                        $("#chat-ratio").next().css("display","block");
                                    }
                                });
                            });


                            let url;
                            if ($(".chat-rank-button-group").find(".layui-this").hasClass("goods")) {
                                url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listGoodsData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                            } else if ($(".chat-rank-button-group").find(".layui-this").hasClass("store")) {
                                url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listStoreData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                            } else if ($(".chat-rank-button-group").find(".layui-this").hasClass("house")) {
                                url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listHouseData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                            }
                            get(url, function (res) {
                                if (!emptyList(res.data)) {
                                    $("#chat-rank").css("display","block");
                                    $("#chat-rank").next().css("display","none");
                                    window.chat_rank_chat.setOption(genChatRankOption(genChatRankData("进货退货额","amount",res.data)));
                                } else {
                                    $("#chat-rank").css("display","none");
                                    $("#chat-rank").next().css("display","block");
                                }
                            });


                            if ($(".chat-ratio-button-group").find(".layui-this").hasClass("goods")) {
                                url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listGoodsData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                            } else if ($(".chat-ratio-button-group").find(".layui-this").hasClass("store")) {
                                url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listStoreData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                            } else if ($(".chat-ratio-button-group").find(".layui-this").hasClass("house")) {
                                url = "${baseUrl}goodsCount/inGoodsRefundAnalysis/listHouseData.action"+genParam(getFormJson($("#searchForm")))+ "&filterZero=true";
                            }

                            get(url, function (res) {
                                if (!emptyList(res.data)) {
                                    $("#chat-ratio").css("display","block");
                                    $("#chat-ratio").next().css("display","none");
                                    window.chat_ratio_chat.setOption(genChatRatioOption(genChatRatioData("进货退货额","amount",res.data)));
                                } else {
                                    $("#chat-ratio").css("display","none");
                                    $("#chat-ratio").next().css("display","block");
                                }
                            });

                            get("${baseUrl}goodsCount/inGoodsRefundAnalysis/listProviderData.action"+genParam(getFormJson($("#searchForm"))) + "&filterZero=true", function (res) {
                                if (!emptyList(res.data)) {
                                    $("#provider-ratio").css("display","block");
                                    $("#provider-ratio").next().css("display","none");
                                    window.provider_ratio_chat.setOption(genChatRatioOption(genChatRatioData("进货退货额","amount",res.data)));
                                } else {
                                    $("#provider-ratio").css("display","none");
                                    $("#provider-ratio").next().css("display","block");
                                }
                            });

                            get("${baseUrl}goodsCount/inGoodsRefundAnalysis/chatDetailData.action"+genParam(getFormJson($("#searchForm"))), function (res) {
                                if (!emptyList(res.data)) {
                                    $("#inGoodsRefund-trend").css("display","block");
                                    $("#inGoodsRefund-trend").next().css("display","none");
                                    let dateList = [];
                                    let amountList = [];
                                    for (let key in res.data) {
                                        dateList.push(key);
                                        amountList.push(getPrice(res.data[key]));
                                    }
                                    window.inGoodsRefund_trend_chat.setOption(genChatLineOption("进货退货额",dateList,amountList));
                                } else {
                                    $("#inGoodsRefund-trend").css("display","none");
                                    $("#inGoodsRefund-trend").next().css("display","block");
                                }
                            });
                        });
                    }
                </script>
            </div>

            <div id="table-div" class="view-div">
                <div class="layui-card">
                    <div class="layui-card-header">
                        <div class="layui-inline">
                            <div class="layui-btn-group tab-button-group">
                                <a view-id="goods-div" view-class="table-div" class="layui-btn layui-btn-normal fontWhite layui-this">按商品</a>
                                <a view-id="provider-div" view-class="table-div" class="layui-btn layui-btn-primary fontBlue">按供应商</a>
                                <a view-id="order-div" view-class="table-div" class="layui-btn layui-btn-primary fontBlue">按单据</a>
                            </div>
                        </div>
                    </div>
                    <div class="layui-card-body">
                        <div id="goods-div" class="table-div mh200 mt10">
                            <div class="layui-inline mb4">
                                <div class="label">过滤零退货</div>
                                <div style="display: inline-block;width: 30px;">
                                    <input type="checkbox" name="filterZero_goods"  title="" lay-skin="primary" value="true" checked lay-filter="filterZero_goods">
                                </div>
                            </div>

                            <div class="layui-inline mb4">
                                <div class="label">商品分类</div>
                                <div style="display: inline-block;width: 160px;">
                                    <select name="typeId_goods" lay-filter="typeId_goods">
                                    </select>
                                </div>
                            </div>

                            <div class="layui-inline mb4">
                                <div class="label">搜索信息</div>
                                <div style="display: inline-block;width: 160px;">
                                    <input type="text" name="search_goods" placeholder="编号、名称、规格、属性" class="layui-input font12">
                                </div>
                            </div>

                            <div class="layui-inline mb4">
                                <div class="layui-btn-group">
                                    <a class="layui-btn " lay-submit="" lay-filter="search_goods" id="btn-search-goods"><i class="layui-icon layui-icon-search"></i></a>
                                    <a class="layui-btn layui-btn-primary" id="export-goods">导出</a>
                                </div>
                            </div>
                            <table class="layui-hide" id="table_goods" lay-filter="table_goods" lay-size="sm"></table>
                        </div>

                        <div id="provider-div" style="display: none"  class="table-div mh200">
                            <div class="layui-inline mb4">
                                <div class="label">过滤零进货退货</div>
                                <div style="display: inline-block;width: 30px;">
                                    <input type="checkbox" name="filterZero_provider"  title="" lay-skin="primary" value="true" checked lay-filter="filterZero_provider">
                                </div>
                            </div>

                            <div class="layui-inline mb4">
                                <div class="label">供应商分类</div>
                                <div style="display: inline-block;width: 160px;">
                                    <select name="providerTypeId_provider" lay-filter="providerTypeId_provider">
                                    </select>
                                </div>
                            </div>

                            <div class="layui-inline mb4">
                                <div class="label">搜索信息</div>
                                <div style="display: inline-block;width: 160px;">
                                    <input type="text" name="search_provider" placeholder="编号、名称" class="layui-input font12">
                                </div>
                            </div>

                            <div class="layui-inline mb4">
                                <div class="layui-btn-group">
                                    <a class="layui-btn " lay-submit="" lay-filter="search_provider" id="btn-search-provider"><i class="layui-icon layui-icon-search"></i></a>
                                    <a class="layui-btn layui-btn-primary" id="export-provider">导出</a>
                                </div>
                            </div>

                            <table class="layui-hide" id="table_provider" lay-filter="table_provider" lay-size="sm"></table>
                        </div>

                        <div id="order-div" style="display: none"  class="table-div mh200">
                            <div class="layui-inline mb4">
                                <div class="layui-btn-group">
                                    <a class="layui-btn layui-btn-primary" id="export-order">导出</a>
                                </div>
                            </div>
                            <table class="layui-hide" id="table_order" lay-filter="table_order" lay-size="sm"></table>
                        </div>
                    </div>

                </div>
            </div>

        </form>
    </div>
</div>
</body>

<script type="text/html" id="operBar">
    <a class="layui-btn layui-btn-xs layui-btn-normal " lay-event="detail">详情</a>
</script>

<html:loading/>
</html>